package de.justphil.tcg.tcgserver.commons.domain.collections;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import de.justphil.tcg.tcgserver.commons.domain.CardInstance;

/* Composition over Inheritance */
public class CardInstanceCollection implements Serializable {
	
	private Collection<CardInstance> ciCollection;

	/**
	 * 
	 */
	private static final long serialVersionUID = -2995787852079959822L;
	
	
	public CardInstanceCollection() {
		ciCollection = new ArrayList<CardInstance>();
	}

	public CardInstanceCollection(int initialCapacity) {
		ciCollection = new ArrayList<CardInstance>(initialCapacity);
	}
	
	public Collection<CardInstance> getCollection() {
		return ciCollection;
	}
	
	public void setCollection(Collection<CardInstance> ciCollection) {
		this.ciCollection = ciCollection;
	}
	
	/* ############################################################################################ */
	/* ############################################################################################ */
	/* ############################################################################################ */
	

	public int size() {
		return ciCollection.size();
	}

	public boolean isEmpty() {
		return ciCollection.isEmpty();
	}

	public boolean contains(Object o) {
		return ciCollection.contains(o);
	}

	public Iterator<CardInstance> iterator() {
		return ciCollection.iterator();
	}

	public Object[] toArray() {
		return ciCollection.toArray();
	}

	public <T> T[] toArray(T[] a) {
		return ciCollection.toArray(a);
	}

	public boolean add(CardInstance e) {
		return ciCollection.add(e);
	}

	public boolean remove(Object o) {
		return ciCollection.remove(o);
	}

	public boolean containsAll(Collection<?> c) {
		return ciCollection.containsAll(c);
	}

	public boolean addAll(Collection<? extends CardInstance> c) {
		return ciCollection.addAll(c);
	}

	public boolean removeAll(Collection<?> c) {
		return ciCollection.removeAll(c);
	}

	public boolean retainAll(Collection<?> c) {
		return ciCollection.retainAll(c);
	}

	public void clear() {
		ciCollection.clear();
	}

	public boolean equals(Object o) {
		return ciCollection.equals(o);
	}

	public int hashCode() {
		return ciCollection.hashCode();
	}

	

	@Override
	public String toString() {
		if (ciCollection == null)
			return "null";
		
		StringBuilder sb = new StringBuilder();
		
		sb.append("[");
		
		int i = 0;
		for (CardInstance ci : ciCollection) {
			sb.append("#").append(ci.getId()).append(": ").append(ci.getCardId());
			
			if (i < ciCollection.size()-1) {
				sb.append(", ");
			}
			
			i++;
		}
		
		sb.append("]");
		
		return sb.toString();
	}
	
	
	
}
